package xyz.ddlnt.management.mg.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import xyz.ddlnt.commonutil.result.Result;
import xyz.ddlnt.model.dto.ExamQuestionDTO;
import xyz.ddlnt.model.dto.PublishStatus;
import xyz.ddlnt.model.vo.ExamQuestionInfoVO;
import xyz.ddlnt.model.vo.ExamQuestionVO;
import xyz.ddlnt.servicemgclient.client.ExamQuestionFeignClient;

import java.util.List;

/**
 * @author ZZULI_SE 210910
 * @data 2025/5/3 23:50
 */
@Slf4j
@Tag(name = "试题管理接口")
@RestController
@RequestMapping(("/exam_question"))
public class ExamQuestionController {
    @Resource
    private ExamQuestionFeignClient examQuestionFeignClient;

    @Operation(summary = "添加试题")
    @PostMapping("/addExamQuestion")
    public Result<ExamQuestionVO> addExamQuestion(@RequestBody ExamQuestionDTO examQuestionDTO) {
        return examQuestionFeignClient.addExamQuestion(examQuestionDTO);
    }

    @Operation(summary = "删除试题")
    @DeleteMapping("/deleteExamQuestion/{id}")
    public Result<Boolean> deleteExamQuestion(@PathVariable Long id) {
        return examQuestionFeignClient.deleteExamQuestion(id);
    }

    @Operation(summary = "修改试题")
    @PutMapping("/updateExamQuestion")
    public Result<ExamQuestionVO> updateExamQuestion(@RequestBody ExamQuestionDTO examQuestionDTO) {
        return examQuestionFeignClient.updateExamQuestion(examQuestionDTO);
    }

    @Operation(summary = "修改试题发布状态")
    @PutMapping("/updatePublishStatus")
    public Result<Boolean> updatePublishStatus(@RequestBody PublishStatus publishStatus) {
        return examQuestionFeignClient.updatePublishStatus(publishStatus);
    }

    @Operation(summary = "查询试题详情")
    @GetMapping("/getExamQuestion/{id}")
    public Result<ExamQuestionInfoVO> getExamQuestion(@PathVariable Long id) {
        return examQuestionFeignClient.getExamQuestionById(id);
    }

    @Operation(summary = "查询试题列表")
    @GetMapping("/getExamQuestionList")
    public Result<List<ExamQuestionVO>> getExamQuestionList() {
        return examQuestionFeignClient.getExamQuestions();
    }
}
